<!DOCTYPE html>
<html lang="zh-cn">

<head>
	<meta charset="utf-8" />
	<title>ko测试</title>
	<script type='text/javascript'src='knockout-3.5.1.debug.js'></script>
</head>

<body>

	<p>First name: <input data-bind="value: firstName, click: blurChange" /></p>
	<p>Last name: <input data-bind="value: lastName" /></p>
	<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
	<ul></ul>
	

</body>

</html>

<script>

	//只是一个普通对象
	var vm = {
		firstName: ko.observable("Planet"),
		lastName: ko.observable("Earth"),
		blurChange: function(){
			console.log('blur')
		}
	}

	vm.fullName = ko.pureComputed(function() {
		// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
		return this.firstName() + " " + this.lastName();
	}, vm);
	
	ko.applyBindings(vm); // This makes Knockout get to work
</script>